function trim(s){
 	return rtrim(ltrim(s)); 
}
function ltrim(s){
 	return s.replace( /^\s*/, ""); 
} 
function rtrim(s){ 
 	return s.replace( /\s*$/, ""); 
}
function isEmpty(s){
	s = trim(s); 
	return s.length == 0; 
}
function isNumber(s){
	return !isNaN(s); 
}
/*
*  验证所填颜色值是否为正确格式
*/ 
function isColor(s){ 
	s = trim(s); 
	if (s.length !=7) return false; 
	return s.search(/\#[a-fA-F0-9]{6}/) != -1; 
}
/*
*  验证所填手机号码是否为正确格式
*/ 
function isMobile(s){ 
	s = trim(s); 
	var p = /13\d{9}/; 
	return p.test(s);
}
/*
*  验证所填身份证是否为正确格式
*/
function isCard(s){ 
	s = trim(s); 
	var p = /^\d{15}(\d{2}[xX0-9])?$/; 
	return p.test(s);
}
/*
*  验证所填URL是否为正确格式
*/
function isURL(s){
	s = trim(s).toLowerCase();
	var p = /^http:\/\/[A-Za-z0-9]+\.[A-Za-z0-9]+[\/=\?%\-&_~`@[\]\':+!]*([^<>\"\"])*$/;
	return p.test(s);
}
/*
*  验证所填Phone是否为正确格式
*/
function isPhone(s){
	s = trim(s);
	var p = /^((\(\d{3}\))|(\d{3}\-))?(\(0\d{2,3}\)|0\d{2,3}-)?[1-9]\d{6,7}$/;
	return p.test(s);
}
/*
*  验证所填Zip是否为正确格式
*/
function isZip(s){
	s = trim(s);
	var p = /^[1-9]\d{5}$/;
	return p.test(s);
}
/*
*  验证所填内容是否为Double类型数据
*/
function isDouble(s){
	s = trim(s);
	var p = /^[-\+]?\d+(\.\d+)?$/;
	return p.test(s);
}
/*
*  验证所填内容是否为Integer类型数据
*/
function isInteger(s){
	s = trim(s);
	var p = /^[-\+]?\d+$/;
	return p.test(s);
}
/*
*  验证所填内容是否为英文
*/
function isEnglish(s){
	s = trim(s);
	var p = /^[A-Za-z]+$/;
	return p.test(s);
}
/*
*  验证所填内容是否为中文
*/
function isChinese(s){
	s = trim(s);
	var p = /^[\u0391-\uFFE5]+$/;
	return p.test(s);
}
/*
*  验证所填内容每位是否为双字节
*/
function isDoubleChar(s){
	var p = /^[^\x00-\xff]+$/;
	return p.test(s);
}
/*
* 验证所填内容是否为Email格式
*/
function isEmail(s){
	s = trim(s); 
 	var p = /^[_\.0-9a-z-]+@([0-9a-z][0-9a-z-]+\.){1,4}[a-z]{2,3}$/i; 
 	return p.test(s);
}
/*
*  验证所填内容是否含有中文字符
*/
function hasChineseChar(s){
	var p = /[^\x00-\xff]/;
	return p.test(s);
}
/*
*  验证是否已经存在如填内容的账号
*/
function hasAccountChar(s){
	var p = /^[a-zA-Z0-9][a-zA-Z0-9_-]{0,15}$/;
	return p.test(s);
}
/*
*  验证所填内容的字符长度
*/
function limitLen(s,Min,Max){
	s=trim(s);
	if(s=="") return false;
	if((s.length<Min)||(s.length>Max))
		return false;
	else
		return true;
}

/*
*  验证所填内容的字节长度
*/
function limitByteLen(s,Min,Max){
	s=trim(s);
	if(s=="") return false;
	var str = mbStringLength(s);
	if((str.length<Min)||(str.length>Max))
		return false;
	else
		return true;
}
/*
*  显示填写是否正确
*/
function showInfo(n,s){
		var fdo = $(n+"FrameDiv");
		var ido = $(n+"InfoDiv");
		if(typeof s == 'undefined'){
			fdo.className = "FrameDivPass";
			ido.innerHTML = "填写正确！";
		}else{
			fdo.className = "FrameDivWarn";
			ido.innerHTML = icon + s;
		}
	}
	
	function mbStringLength(s) {
        var totalLength = 0;
        var i;
        var charCode;
        for (i = 0; i < s.length; i++) {
          charCode = s.charCodeAt(i);
          if (charCode < 0x007f) {
            totalLength = totalLength + 1;
          } else if ((0x0080 <= charCode) && (charCode <= 0x07ff)) {
            totalLength += 2;
          } else if ((0x0800 <= charCode) && (charCode <= 0xffff)) {
            totalLength += 3;
          }
        }
        //alert(totalLength);
        return totalLength;
      } 

	
var icon = '<img src="images/warning.gif" width="14" height="14" border="0" align="absmiddle">';
	